var nodemailer = require("nodemailer");
var config=require("./config")
var transport = nodemailer.createTransport("SMTP", {
    host: "smtp.qq.com",
    secureConnection: true, // use SSL
    port: 465, // port for secure SMTP
    auth: config.email
});
var extend=require('./extend');
module.exports=function(_setting,callback){
    var setting=extend(true, {
        from: "2059093714@qq.com",
        generateTextFromHTML: true
    }, _setting);

    transport.sendMail(setting, function (error, response) {
        if (error) {
            console.error(error);
            if(!!callback)callback(error);
        } else {
            if(!!callback)callback(null,response);
        }
        transport.close();
    });
}